﻿using System;
using System.Collections.Generic;
using System.Text;


public class QueueExample
{
    public static void Test()
    {
        CSeqQueue<int> mySeqQue = new CSeqQueue<int>(5);
        Console.WriteLine(mySeqQue.IsEmpty());
        mySeqQue.In(1);
        mySeqQue.In(2);
        mySeqQue.In(3);
        mySeqQue.In(4);
        Console.WriteLine(mySeqQue.Out());
        mySeqQue.In(5);
        Console.WriteLine(mySeqQue.IsFull());
        Console.WriteLine(mySeqQue.GetFront());
    }

    /// <summary>
    /// 判断是否为回文串
    /// </summary>
    /// <param name="str"></param>
    /// <returns></returns>
    public static bool IsPalindrome(string str)
    {
        SeqStack<char> s = new SeqStack<char>(50);
        CSeqQueue<char> q = new CSeqQueue<char>(50);
        for (int i = 0; i < str.Length; i++)
        {
            s.Push(str[i]);
            q.In(str[i]);
        }

        while (!s.IsEmpty() && !q.IsEmpty())
        {
            if (s.Pop() != q.Out())
            {
                break;
            }
        }

        if (!s.IsEmpty() || !q.IsEmpty())
        {
            return false;
        }
        else
        {
            return true;
        }
    }
}
